package com.eastfair.venuebooking.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 环节名称枚举类
 * </p>
 * @author linan
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SegmentNameEnum", description = "环节名称")
public enum SegmentNameEnum implements BaseEnum {
    /**
     * 布展时间
     */
    ARRANGEMENT_TIME("布展时间"),
    /**
     * 展览时间
     */
    EXHIBITION_TIME("展览时间"),
    /**
     * 撤展时间
     */
    DISMANTLING_TIME("撤展时间"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static SegmentNameEnum match(String val, SegmentNameEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SegmentNameEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(SegmentNameEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "BLANK,PENDING,APPROVE,DISAPPROVE", example = "PENDING")
    public String getCode() {
        return this.name();
    }


}
